package io

import (
	"bufio"
	"bytes"
	"fmt"
	"io/ioutil"
	"strings"
)

func TestBytes() {
	s := "jrwhgfsyuejydfhwuijdhgfwios"
	stringReader := strings.NewReader(s)

	for {
		b, err := stringReader.ReadByte()
		if err != nil {
			fmt.Println("err=" + err.Error())
			break
		}
		fmt.Println(b)
	}

	data := []byte(s)

	bytesReader := bytes.NewReader(data)
	bufReader := bufio.NewReader(bytesReader)

	data2, err := ioutil.ReadAll(bufReader)
	if err != nil {
		fmt.Println("err=" + err.Error())
		return
	}

	fmt.Println(string(data2))

	buf := new(bytes.Buffer)
	for i := 0; i < 100; i++ {
		buf.WriteString("hello world\t")
	}
	fmt.Println(buf.String())

	builder := &strings.Builder{}
	builder.WriteString("aaa")
	builder.WriteString("bbb")

	fmt.Println(builder.String())
}
